package com.cusc.lib_sdk_location_gd.mvvm.ui;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.ViewDataBinding;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.cusc.lib_sdk_location_gd.mvvm.vm.GDMapBaseViewModel;
import com.tcgroup.phone.base_core.framework.mvvm.fragment.BaseMvvmFragment;
/**
 * 作者: wangfei
 * 创建时期: 2020/6/1.
 * 包名: com.cusc.lib_sdk_location_gd.mvvm.ui
 * 类名: OSAndroidMvvm
 */
public abstract class GDMapBaseMvvmFragment<V extends ViewDataBinding> extends
        BaseMvvmFragment<V, GDMapBaseViewModel> {

    private MapView mMapView;
    private AMap mAMap;
    public GDMapBaseMvvmFragment(){ }


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mMapView = setMapView();
        mMapView.onCreate(savedInstanceState);// 此方法必须重写
        mAMap = mMapView.getMap();
    }

    @Override
    public void onPause() {
        super.onPause();
        if (mMapView != null)
            mMapView.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        if (mMapView != null) {
            mMapView.onResume();
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mMapView != null) {
            mMapView.onDestroy();
        }
    }

    @Override
    public void onSaveInstanceState(@NonNull Bundle outState) {
        super.onSaveInstanceState(outState);
        if (mMapView != null) {
            mMapView.onSaveInstanceState(outState);
        }
    }

    public MapView getMapView(){
        return mMapView;
    }

    public AMap getAMap(){
        return mAMap;
    }

    public abstract MapView setMapView();
}
